import direct.directbase.DirectStart
from panda3d.core import TextNode
from panda3d.core import Point2,Point3,Vec3,Vec4
from direct.gui.OnscreenText import OnscreenText
from direct.showbase.DirectObject import DirectObject
from direct.task.Task import Task
from math import sin, cos, pi
from random import randint, choice, random
from direct.interval.MetaInterval import Sequence
from direct.interval.FunctionInterval import Wait,Func
from title_screen import TitleScreen
from main_menu import MainMenu
from camera_controller import CameraController
from sound_loader import SoundLoader
'''
	Andrew Oberlin
	Date: February 27, 2012
	
	Starcraft Main Program
'''
class World(DirectObject):
	WIN_WIDTH = 800.0
	WIN_HEIGHT = 600.0
	'''
		The constructor of the world, starts everything
	'''
	def __init__(self):
		# setup this object to maintain the taskMgr, render node, loader
	    # makes passing this as a parent easier to classes used
	    # for example see the way ActorLoader works
		self.render = render
		self.taskMgr = taskMgr
		self.loader = loader
		self.camera = camera
		self.base = base
		base.disableMouse()
		
		self.base.setBackgroundColor(0,0,0)
		
		self.loadSounds()
		self.setViewpoint()
		
		self.levelEditor = None
		self.singlePlayer = None
		self.titleScreen = TitleScreen(self)
		self.accept("enter", self.showMainMenu)
	
	'''
		Loads all the sounds for the game
	'''
	def loadSounds(self):
		self.soundLoader = SoundLoader(self)
		
	'''
		Sets the viewpoint to be controlled
		by the CameraController
	'''
	def setViewpoint(self):
		self.cameraController = CameraController(self)
	
	'''
		Takes you from the title screen to the menu
	'''
	def showMainMenu(self):
		self.ignore("enter")
		self.titleScreen.hide()
		self.mainMenu = MainMenu(self)
		
	def setLevelEditor(self, levelEditor):
		self.levelEditor = levelEditor
	
	def setSinglePlayer(self, singlePlayer):
		self.singlePlayer = singlePlayer
	
world = World()
run()